﻿using System;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace gt.framework.Configuration.ConfigEntity
{
    [XmlRoot("paramConfig", Namespace = ConfigConstants.DefaultConfigNamespace)]
    public class ParamsConfig : ConfigBase
    {
        [XmlElement("param")]
        public List<ParamEntry> ParamEntries { get; set; }

        public string GetValue(string key)
        {
            ParamEntry entry = this.ParamEntries.Find(e => String.Equals(e.Key, key, StringComparison.InvariantCultureIgnoreCase));
            if (entry != null) return entry.Value;

            return string.Empty;
        }
    }

    public class ParamEntry
    {
        [XmlAttribute("key")]
        public string Key { get; set; }

        [XmlText]
        public string Value { get; set; }
    }
}
